<html>
	<title> Add User </title>
	<body>
		<table>
			<form action="add_user.php" method="GET">
				<tr><td>Firstname</td> <td><input type="text"  name="firstname"></td></tr>
				<tr><td>Lastname </td><td><input type="text" name="lastname"></td></tr>
				<tr><td>Username </td><td><input type="text" placeholder="email" name="username"></td></tr>
				<tr><td>Password </td><td><input type="password" name="pword"></td></tr>
				<tr><td>Usertype </td><td><select name="usertype">
											<option> ADMIN </option>
											<option> CHO </option>
											<option> DHMT </option>
										 </select>	</td></tr>
				<tr> <td><input type="submit" value="ADD" name="submit"></td> </tr>
			</form>
		</table>
		<?php
			include("users.php");
			$obj = new users();
			
			if(!isset($_REQUEST['firstname'])){
				echo "Error- empty input";
				exit();
			}else{
				$userId=0;
				if(isset($_REQUEST['userId'])){
					$userId=$_REQUEST['userId'];
				}
				if(isset($_REQUEST['firstname'])){
					$firstname=$_REQUEST['firstname'];
				}
				if(isset($_REQUEST['lastname'])){
					$lastname=$_REQUEST['lastname'];
				}
				if(isset($_REQUEST['username'])){
					$username=$_REQUEST['username'];
				}
				if(isset($_REQUEST['usertype'])){
					$usertype=$_REQUEST['usertype'];
				}
				if(isset($_REQUEST['pword'])){
					$pword=$_REQUEST['pword'];
				}
				$dateCreated=date("Y/m/d");
			}
		
			if(!$obj->add_user($userId,$firstname,$lastname,$username,$usertype,$pword,$dateCreated)){
				echo "Error ".mysql_error();
				exit();
			}else{
				echo "User Added";
			}
		?>
	</body>
</html>
